package hospital.controller.api;

import hospital.model.hosp.Hospital;
import hospital.model.hosp.Schedule;
import hospital.result.Result;
import hospital.service.DepartmentService;
import hospital.service.HospitalService;
import hospital.service.HospitalSetService;
import hospital.service.ScheduleService;
import hospital.vo.hosp.DepartmentVo;
import hospital.vo.hosp.HospitalQueryVo;
import hospital.vo.hosp.ScheduleOrderVo;
import hospital.vo.order.SignInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author
 * @description: 作用用户前端的查询接口
 */
@Api("作用用户前端的查询接口")
@RestController
@RequestMapping("/api/hosp/hospital")
public class HospitalApiController {
    @Autowired
    private HospitalService hospitalService;
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private ScheduleService scheduleService;
    @Autowired
    private HospitalSetService hospitalSetService;

    /**
     * @Author yang
     * @Description //TODO 查询医院列表
     * @Param [page, limit, queryVo]
     * @return
     **/
    @ApiOperation("查询医院列表")
    @PostMapping("findHospList/{page}/{limit}")
    public Result findHospList(@PathVariable Integer page,
                               @PathVariable Integer limit,
                               HospitalQueryVo queryVo){
        Page<Hospital> list = hospitalService.getHospitalList(page, limit, queryVo);
        return Result.ok(list);
    }

    /**
     * @Author yang
     * @Description //TODO 根据医院的名称，进行模糊查询
     * @Param
     * @return
     **/
    @ApiOperation("据医院的名称，进行模糊查询")
    @GetMapping("findByHosName/{hosname}")
    public Result findByHosName(@PathVariable String hosname){
        List<Hospital> list=hospitalService.findByHosName(hosname);
        return Result.ok(list);
    }

    /**
     * @Author yang
     * @Description //TODO 根据医院编号获取科室
     * @Param [hoscode]
     * @return
     **/
    @ApiOperation("根据医院编号获取科室")
    @GetMapping("findDepartment/{hoscode}")
    public Result findDepartment(@PathVariable String hoscode){
        List<DepartmentVo> list = departmentService.getDepartmentList(hoscode);
        return Result.ok(list);
    }

    /**
     * @Author yang
     * @Description //TODO 根据医院编号获取医院预约挂号的详情
     * @Param [hoscode]
     * @return
     **/
    @ApiOperation("根据医院编号获取医院预约挂号的详情")
    @GetMapping("findHospDetail/{hoscode}")
    public Result findHospDetail(@PathVariable String hoscode){
        Map<String,Object> map=hospitalService.findHospitalDetailByHoscode(hoscode);
        return Result.ok(map);
    }

    /**
     * @Author yang
     * @Description //TODO 获取可预约排班数据
     * @Param
     * @return
     **/
    @ApiOperation(value = "获取可预约排班数据")
    @GetMapping("auth/getBookingScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getBookingSchedule(@PathVariable Integer page,
                                     @PathVariable Integer limit,
                                     @PathVariable String hoscode,
                                     @PathVariable String depcode){
        Map<String, Object> map=scheduleService.getBookingSchedule(page,limit,hoscode,depcode);
        return Result.ok(map);
    }
    /**
     * @Author yang
     * @Description //TODO 获取排班数据
     * @Param
     * @return
     **/
    @ApiOperation(value = "获取排班数据")
    @GetMapping("auth/findScheduleList/{hoscode}/{depcode}/{workDate}")
    public Result findScheduleList(@PathVariable String hoscode,
                                   @PathVariable String depcode,
                                   @PathVariable String workDate){
        List<Schedule> list=scheduleService.getDetailSchedule(hoscode,depcode,workDate);
        return Result.ok(list);
    }
    
    /**
     * @Author yang
     * @Description //TODO 根据排班的id，获取排班的详情
     * @Param
     * @return 
     **/
    @ApiOperation("根据排班的id，获取排班的详情")
    @GetMapping("getSchedule/{scheduleId}")
    public Result getSchedule(@PathVariable String scheduleId){
        Schedule schedule=scheduleService.getSchedule(scheduleId);
        return Result.ok(schedule);
    }

    /**
     * @Author yang
     * @Description //TODO 根据排班id获取预约下单数据
     * @Param [scheduleId]
     * @return
     **/
    @ApiOperation(value = "根据排班id获取预约下单数据")
    @GetMapping("inner/getScheduleOrderVo/{scheduleId}")
    public ScheduleOrderVo getScheduleOrderVo(
            @ApiParam(name = "scheduleId", value = "排班id", required = true)
            @PathVariable("scheduleId") String scheduleId) {
        return scheduleService.getScheduleOrderVo(scheduleId);
    }

    /**
     * @Author yang
     * @Description //TODO 获取医院签名信息
     * @Param
     * @return
     **/
    @ApiOperation(value = "获取医院签名信息")
    @GetMapping("inner/getSignInfoVo/{hoscode}")
    public SignInfoVo getSignInfoVo(
            @ApiParam(name = "hoscode", value = "医院code", required = true)
            @PathVariable("hoscode") String hoscode) {
        return hospitalSetService.getSignInfoVo(hoscode);
    }
}
